home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 40
/
Amiga Format CD40 (1999-05-11)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-06].iso
/
-seriously_amiga-
/
misc
/
blankpurge
/
blankpurge.bas
< prev
next >
Wrap
BASIC Source File
|
1999-03-29
|
3KB
|
154 lines
REM Blank Purger 1.2 by Simon N Goodwin, February 1999.
REM
REM WHAT?
REM
REM Program to scan a text file and remove blank lines.
REM
REM REQUIREMENTS
REM
REM Written in HiSoft BASIC. Requires ASL library.
REM Uses 15 point Helvetica.font if it's available.
REM
REM HOW?
REM
REM Start from Workbench by clicking on the icon.
REM Select a file to be scanned or CANCEL to quit.
REM Repeat selection for each file to be purged.
REM
REM Input file is not modified. A new file on the
REM same path with the suffix ".purged" is created
REM containing the original contents except with
REM the blank lines removed.
REM
REM KNOWN BUGS
REM
REM No check that the output file name is valid.
REM
REM FUTURE
REM
REM Progress display - tricky without a prior scan.
REM
REM Could be extended to skip lines with no semantic
REM content - e.g. containing only spaces or tabs,
REM or empty comment lines (white space optionally
REM either side of a REM, * or ; null line comment)
REM
REM Might also strip redundant CHR$(13)s, though
REM that's easily done with Frank Swift's CRLF tool.
REM
REM STATUS
REM
REM Freely distributable; you must include source.
REM
REM AUTHOR
REM
REM Simon N Goodwin, simon@studio.woden.com
REM
DEFINT a-z
' HiSoft ASL library and disk font initialisation
REM $INCLUDE diskfont.bh
REM $INCLUDE graphics.bh
REM $include asl.bh
LIBRARY OPEN "asl.library"
LIBRARY OPEN "diskfont.library"
LIBRARY OPEN "graphics.library"
WINDOW 1," Amiga File Blank Line Purger v1.2 ", _
(64,60)-(408,100),1+2+4+16+256
REM Use a groovier Compugraphic fo(u)nt if you wish
DIM TextAttr(4)
InitTextAttr TextAttr(),"Helvetica.font",15,0,0
font& = OpenDiskFont (VARPTR(TextAttr(0)))
IF font&
SetFont WINDOW (8), font&
ELSE
PRINT " **** Preferred font not available. Using default."
END IF
' ASL requester initialisation
CONST TAG_DONE&=0,TRUE&=1,ABORT&=-1,FALSE&=0
DIM frtags&(20)
' Main program
ok=TRUE
REPEAT main
TAGLIST VARPTR(frtags&(0)),ASLFR_TitleText&, _
"Select the file to be purged", _
ASLFR_InitialFile&,"", _
ASLFR_InitialDrawer&,"RAM:", _
ASLFR_InitialHeight&, 130, _
ASLFR_InitialLeftEdge&, 280, _
ASLFR_InitialWidth&, 310, _
TAG_DONE&
fr&=AllocAslRequest&(ASL_FileRequest&,VARPTR(frtags&(0)))
IF fr& THEN
ok&=AslRequest&(fr&,0)
IF ok& THEN
file$=PEEK$(PEEKL(fr&+fr_File))
dir$=PEEK$(PEEKL(fr&+fr_Drawer))
IF LEN(dir$)
suffix$=RIGHT$(dir$,1)
IF suffix$<>"/" AND suffix$<>":" THEN dir$=dir$+"/"
END IF
END IF
FreeASlRequest fr&
ELSE
ok&=ABORT&
END IF
IF ok&=FALSE& OR ok&=ABORT& THEN EXIT main
file$=dir$+file$
PRINT
OPEN file$ FOR INPUT AS #3
OPEN file$+".purged" FOR OUTPUT AS #4
PRINT " Scanning ";file$
found&=0
REPEAT scan
IF EOF(3) THEN EXIT scan
LINE INPUT #3,a$
IF LEN(a$)
PRINT #4,a$ :REM debug PRINT a$
ELSE
found&=found&+1
END IF
END REPEAT scan
CLOSE #4
CLOSE #3
PRINT
PRINT " OK,";found&;"empty lines";
IF found&<>1 THEN PRINT "s";
PRINT " found."
PRINT
PRINT " Condensed version written to ";file$+".purged"
END REPEAT main
SYSTEM
SUB InitTextAttr(T(1),FontName$,BYVAL Height,BYVAL style,BYVAL flags)
POKEL VARPTR(T(0))+ta_Name,SADD(FontName$+CHR$(0))
t(ta_YSize\2)=Height
POKEB VARPTR(T(0))+ta_Style,style
POKEB VARPTR(T(0))+ta_Flags,flags
END SUB ' InitTextAttr